import org.apache.kudu.client.*;

//Kudu API查询数据
public class SelectDemo {
    public static void main(String[] args) {
        //获取客户端
        KuduClient.KuduClientBuilder builder = new KuduClient.KuduClientBuilder("linux121");
        builder.defaultSocketReadTimeoutMs(5000);
        KuduClient client = builder.build();

        try {
            //打开一张表
            KuduTable student = client.openTable("student");
            KuduScanner scanner = client.newScannerBuilder(student).build();
            while (scanner.hasMoreRows()){
                for (RowResult row : scanner.nextRows()) {
                    int id = row.getInt("id");
                    String name = row.getString("name");
                    System.out.println("id:" + id + " name:" + name);
                }
            }
        } catch (KuduException e) {
            e.printStackTrace();
        } finally {
            try {
                client.close();
            } catch (KuduException e) {
                e.printStackTrace();
            }
        }
    }
}
